// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import vuex from 'vuex'
// import Socket from './components/common/Socket'
import stores from './stores'
Vue.use(vuex)
Vue.use(ElementUI)
Vue.config.productionTip = false

//vuex
const store = new vuex.Store({
  modules: stores,
});




var instance = axios.create({
  baseURL: 'http://118.89.39.203',
  timeout: 1000

  //头部放这
  // headers: {'X-Custom-Header': 'foobar'}
});

//拦截器
//401 422 等放着
instance.interceptors.response.use(
response => {
  // if(response.status == 200){
  //      // console.log(router.replace('/home'))
  //      Promise.reject('??')
  // }
    return response;
},
error => {
    if (error.response) {
        // console.log(error)
    }
    return Promise.reject(error.response)   // 返回接口返回的错误信息
});
Vue.prototype.$axios = instance
// Vue.prototype.$socket = Socket

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
